package com.exject.android.socialphonebook.data;


public class Address {
	private Type type;
	private String poBox;
	private String street;
	private String city;
	private String state;
	private String postalCode;
	private String country;
	private String asString;

	public Address(final Type type, final String poBox, final String street, final String city,
			final String state, final String postal, final String country) {
		this.setPoBox(poBox);
		this.setStreet(street);
		this.setCity(city);
		this.setState(state);
		this.setPostalCode(postal);
		this.setCountry(country);
		this.setType(type);
	}

	public Address(final Type type, final String asString) {
		this.asString = asString;
		
		this.type = type;
	}

	public String getCity() {
		return this.city;
	}

	public String getCountry() {
		return this.country;
	}

	public String getPoBox() {
		return this.poBox;
	}

	public String getPostalCode() {
		return this.postalCode;
	}

	public String getState() {
		return this.state;
	}

	public String getStreet() {
		return this.street;
	}

	public Type getType() {
		return this.type;
	}

	public void setCity(final String city) {
		this.city = city;
	}

	public void setCountry(final String country) {
		this.country = country;
	}

	public void setPoBox(final String poBox) {
		this.poBox = poBox;
	}

	public void setPostalCode(final String postalCode) {
		this.postalCode = postalCode;
	}

	public void setState(final String state) {
		this.state = state;
	}

	public void setStreet(final String street) {
		this.street = street;
	}

	public void setType(final Type type) {
		this.type = type;
	}

	private void splitString() {
	    // TODO: Split String!
	}
	
	@Override
	public String toString() {
		if (this.asString.length() > 0) {
			return (this.asString);
		} else {
			String addr = "";
			if (this.getPoBox() != null) {
				addr = addr + this.getPoBox() + "n";
			}
			if (this.getStreet() != null) {
				addr = addr + this.getStreet() + "n";
			}
			if (this.getCity() != null) {
				addr = addr + this.getCity() + ", ";
			}
			if (this.getState() != null) {
				addr = addr + this.getState() + " ";
			}
			if (this.getPostalCode() != null) {
				addr = addr + this.getPostalCode() + " ";
			}
			if (this.getCountry() != null) {
				addr = addr + this.getCountry();
			}
			return (addr);
		}
	}
}